package user

import (
	"blog/app/models"
	"blog/pkg/route"
)

type User struct {
	models.BaseModel

	Name     string `gorm:"type:varchar(255);not null;unique" valid:"name"`
	Email    string `gorm:"type:varchar(255);default:NULL;unique;" valid:"email"`
	Password string `gorm:"type:varchar(255)" valid:"password"`
	//gorm:"-" --设置GORM 在读写时忽略此字段
	PasswordConfirm string `gorm:"-" valid:"password_confirm"`
}

// Link 方法用来生成用户链接
func (user User) Link() string {
	return route.Name2URL("users.show", "id", user.GetStringID())
}
